class Pig extends Animal{
    private double length;
    private double height;
    private String color;

    public Pig(){};

    public Pig(String name, int age, String gender, int legNum, double weight, double length, double height, String color)
    {
        //super是java中的关键字，作用是调用父类中第一句（构造函数）
        super(name,age, gender,legNum, weight);
        this.length = length;
        this.height = height;
        this.color = color;
    }

    @Override
    public String toString()
    {
        return "Pig {" +
                "name" + name + '\'' +
                "age" + age + '\'' +
                "gender" + gender + '\'' +
                "legNum" + legNum + '\'' +
                "weight" + weight + '\'' +
                "length" + length + '\'' +
                "height" + height + '\'' +
                "color" + color + '\'' +
                "}";
    }

    @Override
    public void eatting(String Food)
    {
        String[] eatFoods = {"白菜", "玉米", "红薯"};
        for(String eatFood : eatFoods)
        {
            if(eatFood.equals(Food))
            {
                System.out.println(name + "正在吃" + Food);
            }
            return;
        }
        System.out.println(name + "不吃" + Food);
    }

    public void walking()
    {
        System.out.println(name + "正在行走");
    }
}

